<template>
	<view class="oinpsou">
		<!-- <u-search placeholder="输入企业名称" v-model="keyword" @custom="sousuo" @change="sousuo"></u-search> -->
          <view class='search acea-row row-between-wrapper'>
          	<view class='input acea-row row-between-wrapper'>
          		<text class='iconfont icon-sousuo'></text>
          		<input type='text' v-model='keyword' @confirm="sousuo" focus :placeholder='`输入企业名称`'
          			placeholder-class='placeholder' @input="sousuo"></input>
          	</view>
          	<view class='bnt' @tap='sousuo'>{{`搜索`}}</view>
          </view>
		<div class="borde"></div>
		<div class="okeing" v-if="!keyword">
			<image :src="imgHost + '/sousuo.png'" mode=""></image>
			<p>请在上方搜索企业加入</p>
			<p>或返回选择我是BOSS创建企业</p>
		</div>
		<div class="houke" v-else>
			<span @click="tiao(item)" v-for="(item,index) in suosoulist" :key="index">{{item.name}}</span>
		</div>
	</view>
</template>

<script>
	import {
		HTTP_REQUEST_URL
	} from '@/config/app.js';
	import {
		get_enterprise
	} from '@/api/userminp.js'
	export default {
		data() {
			return {
				imgHost: HTTP_REQUEST_URL + '/mingpian',
				keyword: '',
				suosoulist: []
			};
		},
		onShow() {},
		methods: {
			// 搜索企业
			sousuo() {
				if (!this.keyword) {
					this.suosoulist = []
				} else {
					this.get_pos()
				}
			},
			get_pos() {
				get_enterprise({
					name: this.keyword
				}).then((res) => {
					this.suosoulist = res.data.list
					console.log(this.suosoulist);
				})
			},
			tiao(item) {
				uni.setStorageSync("enterprise"+item.id+"default",JSON.stringify(item.set_up))
				uni.setStorageSync("enterprise"+item.id+"share_check_text",item.share_check_text)
				uni.navigateTo({
					url: '/pages/userminp/bianjimp/bianjimp?name=' + item.name + '&logo=' + item.logo+'&uid='+item.id+'&address='+item.address+'&type_name='+item.type_name+'&mer_id='+item.mer_id
				})
			}
		}	
	}
</script>

<style lang="scss">
     .search{
          background-color: #eee;
          padding: 10rpx 10rpx;
          border-radius: 50rpx;
          .iconfont{
               margin-right: 20rpx;
          }
     }
	.houke {
		margin-top: 40rpx;

		span {
			border-bottom: 2rpx solid #EEE;
			display: block;
			padding: 25rpx 20rpx;
			font-weight: 400;
			font-size: 28rpx;
			line-height: 44rpx;
			color: #161616;
		}
	}

	page {
		background-color: #fff;
	}

	.oinpsou {
		padding: 48rpx;

		.borde {
			margin-top: 40rpx;
			background-color: #eee;
			width: 100%;
			height: 2rpx;
		}
	}

	/deep/.u-action-active[data-v-1a326067] {
		color: #E33C21;
	}

	.okeing {
		margin-top: 250rpx;
		text-align: center;

		image {
			width: 335.42rpx;
			height: 363.34rpx;
		}

		p {
			font-weight: 400;
			font-size: 28rpx;
			line-height: 44rpx;
			color: #999;
		}
	}
</style>
